package com.flexcloudsdk.framework.facade
{
    import com.flexcloudsdk.framework.controller.CloudController;
    import com.flexcloudsdk.framework.interfaces.ICloudController;
    import com.flexcloudsdk.framework.interfaces.ICloudDocument;
    import com.flexcloudsdk.framework.interfaces.ICloudFacade;
    import com.flexcloudsdk.framework.interfaces.ICloudView;
    import com.flexcloudsdk.framework.model.CloudDocument;
    import com.flexcloudsdk.framework.view.CloudView;

    public class CloudFacade implements ICloudFacade
    {
        private var views:Vector.<CloudView>                 = new Vector.<CloudView>();
        private var controllers:Vector.<CloudController> = new Vector.<CloudController>();;
        private var models:Vector.<CloudDocument>     =  new Vector.<CloudDocument>();
        private static var instance:CloudFacade = null;
        
        public function CloudFacade()
        {
        }
        
        public static function getInstance():CloudFacade
        {
            if (instance)
                return instance;
            else
            {
                instance = new CloudFacade();
                // create a default mode, view and controller
                instance.createDocument();
                instance.createController();
                instance.createView();
                return instance
            }
        }
            
        public function shutdown():void
        {
        }
        
       
        public function createController():ICloudController
        {
            controllers.push(new CloudController());
            return controllers[controllers.length - 1];
        }
   
        public function createDocument():ICloudDocument
        {
            models.push(new CloudDocument());
            return models[models.length -1];
        }
            
        public function createView():ICloudView
        {
           views.push(new CloudView()); 
           return views[views.length - 1];   
        }
        
        //-----------------------
        // properties
        //------------------------
        private var _useHTTPAccess:Boolean = true;
        public function set useHTTPAccess(value:Boolean):void
        {
            if (value == _useHTTPAccess)
                    return;
            _useHTTPAccess = value;
        }
        public function get useHTTPAccess():Boolean
        {
                return _useHTTPAccess;
        }
        
        private var _useAMFAccess:Boolean = false;
        public function set useAMFAccess(value:Boolean):void
        {
            if (value == _useAMFAccess)
                return;
            _useAMFAccess = value;
        }
        public function get useAMFAccess():Boolean
        {
            return _useAMFAccess;
        }
        
        private var _useJSONAccess:Boolean = false;
        public function set useJSONAccess(value:Boolean):void
        {
            if (value == _useJSONAccess)
                return;
            _useJSONAccess = value;
        }
        public function get useJSONAccess():Boolean
        {
            return _useJSONAccess;
        }
        
    }
}